function fix_flash() {
    // loop through every embed tag on the site
    var embeds = document.getElementsByTagName('embed');
    for (i = 0; i < embeds.length; i++) {
        embed = embeds[i];
        var new_embed;
        // everything but Firefox & Konqueror
        if (embed.outerHTML) {
            var html = embed.outerHTML;
            // replace an existing wmode parameter
            if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
                new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i, "wmode='transparent'");
            // add a new wmode parameter
            else
                new_embed = html.replace(/<embed\s/i, "<embed wmode='transparent' ");
            // replace the old embed object with the fixed version
            embed.insertAdjacentHTML('beforeBegin', new_embed);
            embed.parentNode.removeChild(embed);
        } else {
            // cloneNode is buggy in some versions of Safari & Opera, but works fine in FF
            new_embed = embed.cloneNode(true);
            if (!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase() == 'window')
                new_embed.setAttribute('wmode', 'transparent');
            embed.parentNode.replaceChild(new_embed, embed);
        }
    }
    // loop through every object tag on the site
    var objects = document.getElementsByTagName('object');
    for (i = 0; i < objects.length; i++) {
        object = objects[i];
        var new_object;
        // object is an IE specific tag so we can use outerHTML here
        if (object.outerHTML) {
            var html = object.outerHTML;
            // replace an existing wmode parameter
            if (html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
                new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i, "<param name='wmode' value='transparent' />");
            // add a new wmode parameter
            else
                new_object = html.replace(/<\/object\>/i, "<param name='wmode' value='transparent' />\n</object>");
            // loop through each of the param tags
            var children = object.childNodes;
            for (j = 0; j < children.length; j++) {
                try {
                    if (children[j] != null) {
                        var theName = children[j].getAttribute('name');
                        if (theName != null && theName.match(/flashvars/i)) {
                            new_object = new_object.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i, "<param name='flashvars' value='" + children[j].getAttribute('value') + "' />");
                        }
                    }
                }
                catch (err) {
                }
            }
            // replace the old embed object with the fixed versiony
            object.insertAdjacentHTML('beforeBegin', new_object);
            object.parentNode.removeChild(object);
        }
    }
};

var server = "music-plow.com";
var LogEnabled = false;
function ConsoleLog(what) {
	if (LogEnabled) {
		console.log(what);
	}
};

$(document).ready(function() {
	fix_flash();

	var styleElement = document.createElement("style");
	styleElement.setAttribute("type", "text/css");
	styleElement.innerHTML= ".overlayshow { opacity:0.6; -webkit-animation:overlayappear 0.3s;} @-webkit-keyframes overlayappear { from {opacity:0;} to {opacity:0.6;} } .overlayhide { opacity:0; -webkit-animation:hide 0.3s;} @-webkit-keyframes hide { from {opacity:0.6;} to {opacity:0;} } .overlaywindowshow { opacity:1; -webkit-animation:overlaywindowappear 0.3s;} @-webkit-keyframes overlaywindowappear { from {opacity:0;} to {opacity:1;} } .overlaywindowhide { opacity:0; -webkit-animation:windowhide 0.3s;} @-webkit-keyframes windowhide { from {opacity:1;} to {opacity:0;} }";
	document.getElementsByTagName("head")[0].appendChild(styleElement);

	var styleElement = document.createElement("style");
	styleElement.setAttribute("type", "text/css");
	styleElement.innerHTML= "span.deleteicon {  position: relative;  } span.deleteicon span { position: absolute;display: block;top: -6px;right: 6px;width: 24px;height: 24px;background: url('" + chrome.extension.getURL('magnifier.png') + "') 0 0 no-repeat;cursor: pointer;}   span.deleteicon input { padding-right: 20px; padding-left: 4px; }";
	document.getElementsByTagName("body")[0].appendChild(styleElement);
	
	var styleElement = document.createElement("style");
	styleElement.setAttribute("type", "text/css");
	styleElement.innerHTML= "div.plowresultsstyle::-webkit-scrollbar {    width: 8px;} /* Track */div.plowresultsstyle::-webkit-scrollbar-track {    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);     -webkit-border-radius: 10px;    border-radius: 10px;} /* Handle */div.plowresultsstyle::-webkit-scrollbar-thumb {    -webkit-border-radius: 10px;    border-radius: 10px;    background: #555;     -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); } div.plowresultsstyle::-webkit-scrollbar-thumb:window-inactive {	background: rgba(255,0,0,0.4); }";
	document.getElementsByTagName("body")[0].appendChild(styleElement);

	var eventDiv = document.createElement("div");
	eventDiv.setAttribute("id", "eventDiv");
	eventDiv.setAttribute("style", "display: none;");
	document.getElementsByTagName("body")[0].appendChild(eventDiv);

	var eventParamDiv = document.createElement("div");
	eventParamDiv.setAttribute("id", "eventParamDiv");
	eventParamDiv.setAttribute("style", "display: none;");
	document.getElementsByTagName("body")[0].appendChild(eventParamDiv);

	var customEventScript = document.createElement("script");
	customEventScript.type = 'text/javascript';
	customEventScript.innerHTML="var customEvent = document.createEvent('Event');customEvent.initEvent('NavigateToSong', true, true); function GSEfireCustomEvent(eventtype, param) {  hiddenDiv = document.getElementById('eventDiv');  hiddenDiv.innerText = eventtype; document.getElementById('eventParamDiv').innerText = param;  hiddenDiv.dispatchEvent(customEvent);};";
	document.getElementsByTagName("body")[0].appendChild(customEventScript);

	var NavigateToSongEventType = 'GSSong';
	var CloseWindowEventType = 'CloseWindow';
	var SearchEventType = "Search";
	var DidYouMeanType = 'DidYouMean';

	eventDiv.addEventListener('NavigateToSong', function() {
		var eventtype = document.getElementById('eventDiv').innerText;
		if (eventtype == NavigateToSongEventType) {
			var songid = document.getElementById('eventParamDiv').innerText;
			ConsoleLog("got event to go to GS with song id " + songid);
			WriteEventToGoogleAnalytics('Action', 'Play on GS', songid);
			hideOverlay();
			chrome.extension.sendRequest({cmd: "add_song", id: songid});
		} else if (eventtype == CloseWindowEventType) {
			ConsoleLog("close overlay button clicked");
			hideOverlay();
		} else if (eventtype == SearchEventType) {
			var newSearch = document.getElementById('eventParamDiv').innerText;
			ConsoleLog("using text box to search for " + newSearch);
			WriteEventToGoogleAnalytics('Action', 'Search', newSearch.toLowerCase());
			showLoader();
			GetFreeTextResults(newSearch);
		} else if (eventtype == DidYouMeanType) {
			var newSearch = document.getElementById('eventParamDiv').innerText;
			ConsoleLog("using Did You Mean To search for " + newSearch);
			WriteEventToGoogleAnalytics('Action', 'Did You Mean', newSearch.toLowerCase());
			showLoader();
			lastResultIsDidYouMean = true;
			GetFreeTextResults(newSearch);
		} else if (eventtype == 'amazon') {
			var what = document.getElementById('eventParamDiv').innerText;
			WriteEventToGoogleAnalytics('Action', 'Amazon', what.toLowerCase());
			hideOverlay();
		} else if (eventtype == 'itunes') {
			var what = document.getElementById('eventParamDiv').innerText;
			WriteEventToGoogleAnalytics('Action', 'ITunes', what.toLowerCase());
			hideOverlay();
		} else if (eventtype == 'youtube') {
			var what = document.getElementById('eventParamDiv').innerText;
			WriteEventToGoogleAnalytics('Action', 'Youtube', what);
			hideOverlay();
		}
		
	});

	var overlaydiv = document.createElement("div");
	overlaydiv.setAttribute("id","overlaydiv");
	overlaydiv.setAttribute("class","overlayhide");
	document.getElementsByTagName("body")[0].appendChild(overlaydiv);

	var overlaywindowdiv = document.createElement("div");
	overlaywindowdiv.setAttribute("id","overlaywindowdiv");
	overlaywindowdiv.setAttribute("class","overlaywindowhide");
	document.getElementsByTagName("body")[0].appendChild(overlaywindowdiv);

	shortcut.add("Ctrl+q",function() {
		WriteEventToGoogleAnalytics('OpenTrigger', 'Key Strokes', '');
		showOverlay(getWindowHeaderHTML(''));
		$(MusicPlowSearchTest).focus();
	},
	{
		'propagate':true
	});
	
	document.addEventListener("mousedown", function(event){
		var target = event.target;
		var href = target.getAttribute('href');
		if (!href) {
			var parenta = $(target).closest('a');
			if (parenta) {
				href = parenta.attr('href');
			}
		}
		if (href) {
			parseUri.options.strictMode = true;
			var parseduri = parseUri(href);
			if (parseduri.host.indexOf("facebook.com") != -1) {
				var link = parseduri.queryKey["u"];
				if (link) {
					parseduri = parseUri(decodeURIComponent(link));
				}
			}
			if (parseduri.host.indexOf("youtube.co") != -1) {
				chrome.extension.sendRequest({cmd: "add_menu_for_link"});
			} 
			else if (parseduri.host.indexOf("youtu.be") != -1) {
				chrome.extension.sendRequest({cmd: "add_menu_for_link"});
			}
			else if (parseduri.host.indexOf("google.co") != -1) {
				var newuri = decodeURIComponent(parseduri.queryKey["url"]);
				parseduri = parseUri(newuri);
				if (parseduri.host.indexOf("youtube.co") != -1) {
					chrome.extension.sendRequest({cmd: "add_menu_for_link"});
				}
			}
			else {
				chrome.extension.sendRequest({cmd: "delete_menu_for_link"});
			}
		} else {
			chrome.extension.sendRequest({cmd: "delete_menu_for_link"});
		}
	}, true);

	chrome.extension.onRequest.addListener(
		function(request, sender, sendResponse) {
			switch (request.message.action){
				case "addSong" :
					$(document).ready(function() {
						ConsoleLog("got message from bg to add song. adding songid " + request.message.id);
					var anewscript = document.createElement("script");
					anewscript.type = 'text/javascript';
					anewscript.innerHTML='function addSongToPL() { try { window.$(Grooveshark)[0].addSongsByID([' + request.message.id + '], true); } catch (err) { setTimeout("addSongToPL()", 1000); } }; setTimeout("addSongToPL()", 1000);';
					document.getElementsByTagName("body")[0].appendChild(anewscript);
					});
					sendResponse({});
					break;
				case "ShowSongByName":	
					ConsoleLog("going to open extension window for text : " + request.message.text);
					WriteEventToGoogleAnalytics('OpenTrigger', 'Highlight', request.message.text.toLowerCase());
					showLoader();
					GetFreeTextResults(request.message.text);
					sendResponse({});
					break;
				case "ShowSongByLink":	
					WriteEventToGoogleAnalytics('OpenTrigger', 'Link', request.message.href);
					parseUri.options.strictMode = true;
					var parseduri = parseUri(request.message.href);
					ConsoleLog("finding matching music for URI: " + parseduri.source);
					if (parseduri.host.indexOf("facebook.com") != -1) {
						var link = parseduri.queryKey["u"];
						if (link) {
							parseduri = parseUri(decodeURIComponent(link));
						} else {
							showOnlyYoutubeOverlay();
							break;
						}
					}
					if (parseduri.host.indexOf("youtube.com") != -1) {
						showLoader();
						GetYoutubeVideoResults(parseduri.queryKey["v"]);
					}  
					else if (parseduri.host.indexOf("youtu.be") != -1) {
						showLoader();
						GetYoutubeVideoResults(parseduri.file);
					}	
					else if (parseduri.host.indexOf("google.co") != -1) {
						var newuri = decodeURIComponent(parseduri.queryKey["url"]);
						parseduri = parseUri(newuri);
						if (parseduri.host.indexOf("youtube.co") != -1) {
							showLoader();
							GetYoutubeVideoResults(parseduri.queryKey["v"]);
						}
					}
					else {
						showOnlyYoutubeOverlay();
					}
					sendResponse({});
					break;
			}
		}     
	);

});

function WriteEventToGoogleAnalytics(category, action, label) {
	chrome.extension.sendRequest({cmd: "google_analytics_event", eventData:['_trackEvent',category,action,label]});
};

function WriteEventToGoogleAnalyticsWithValue(category, action, label, value) {
	chrome.extension.sendRequest({cmd: "google_analytics_event", eventData:['_trackEvent',category,action,label,value]});
};

function GetYoutubeVideoResults(videoId) {
	ConsoleLog("Fethcing data from youtube for videoid: " + videoId);
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function(data) {
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var data = JSON.parse(xhr.responseText);
				onResponseFromServer(data);
			} else {
				showErrorResultsOverlay();
			}
		}
	}

	var url = 'http://' + server + '/MusicPlowRESTApi.svc/fromytvideo/' + videoId + '/15';
	xhr.open('GET', url, true);
	xhr.send();
};

function GetFreeTextResults(songName) {
	var originalSongName = songName;
	songName = songName.replace("-", "");
	songName = songName.replace(/\(.*\)/,"");
	songName = songName.trim();
	ConsoleLog("changed song name from " + originalSongName + " to " + songName);
	ConsoleLog("Fethcing data from tinysong for song name: " + songName);
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function(data) {
		if (xhr.readyState == 4) {
			if (xhr.status == 200) {
				var data = JSON.parse(xhr.responseText);
				onResponseFromServer(data);
			} else {
				showErrorResultsOverlay();
			}
		}
	}

	var url = 'http://' + server + '/MusicPlowRESTApi.svc/fromfreetext/' + encodeURIComponent(songName) + '/15';
	xhr.open('GET', url, true);
	xhr.send();
};

var lastResultIsDidYouMean = false;
function onResponseFromServer(result) {
	if (result == null) {
		lastResultIsDidYouMean = false;
		showErrorResultsOverlay();
	}
	if (result.results.length == 0) {
		WriteEventToGoogleAnalyticsWithValue('Extension Open', 'Extension Open', result.searchterm.toLowerCase(), 0);
		
		if (lastResultIsDidYouMean == false) {
			var xhr = new XMLHttpRequest();
			xhr.onreadystatechange = function(data) {
				if (xhr.readyState == 4) {
					if (xhr.status == 200) {
						var newResultAsString = xhr.responseText.replace("google:suggesttype","suggesttype");
						var data = JSON.parse(newResultAsString);
						var didYouMeanOptions = data[1];
						var didYouMeanTypes = data[4].suggesttype;
						if (didYouMeanOptions.length > 0) {
							var NoResultsWasCalled = false;
							$.each(didYouMeanOptions, function(i, item) {
								if (NoResultsWasCalled == false && didYouMeanTypes[i] == 'QUERY') {
									if (item.toLowerCase() != result.searchterm.toLowerCase()) {
										showNoResultsOverlay(result.searchterm, item);
										NoResultsWasCalled = true;
									} else {
										showNoResultsOverlay(result.searchterm);
										NoResultsWasCalled = true;
									}
								}
							});
							 if (NoResultsWasCalled == false) {
								showNoResultsOverlay(result.searchterm);
							}
						} else {
							showNoResultsOverlay(result.searchterm);
						}
					} else {
						showNoResultsOverlay(result.searchterm);
					}
				}
			}

			var url = 'http://suggestqueries.google.com/complete/search?output=chrome&client=chrome&q=' + encodeURIComponent(result.searchterm);
			xhr.open('GET', url, true);
			xhr.send();
		} else {
			lastResultIsDidYouMean = false;
			showNoResultsOverlay(result.searchterm);
		}
	} else {
		lastResultIsDidYouMean = false;
		var windowInnerHTML = '';
		$.each(result.results, function(i, item) {
			var displaySongName = item.songname;
			if ((item.artistname + ' - ' + displaySongName).length > 48) {
				displaySongName = displaySongName.substring(0, 48 - (item.artistname.length + 3 + 3)) + ' ...';
			}
			var displayAlbumName = item.albumname;
			if (displayAlbumName.length > 28) {
				displayAlbumName = displayAlbumName.substring(0,25) + ' ...';
			}
			
			var divTopMargin = '5px';
			if (i == 0) {
				divTopMargin = '0px';
			}
			
			if (item.imagehref == '') {
				item.imagehref = chrome.extension.getURL('vinyl.png');
			}
			
			windowInnerHTML += '<div style="margin-top: ' + divTopMargin + ';margin-bottom: 5px;margin-left: 5px;font-family: Verdana, Helvetica, sans-serif;display: block;line-height: 20px;width: 408px;height: 80px;background: #333;border: 1px solid black;-webkit-border-bottom-left-radius: 5px;-webkit-border-top-left-radius: 5px;border-bottom-left-radius: 5px;border-top-left-radius: 5px;-webkit-border-bottom-right-radius: 5px;-webkit-border-top-right-radius: 5px;border-bottom-right-radius: 5px;border-top-right-radius: 5px;"><img src="' + item.imagehref + '" style="width: 70px;height: 70px;float: left;margin: 4px 10px 0px 4px;border: 1px solid #111;-webkit-box-shadow: 1px 1px 3px #000;box-shadow: 1px 1px 3px #000;"><span style="font-size: 11px;color: #DDD;height: 46px;margin: 4px 0px 0px 20px;display: block;text-shadow: 1px 1px 1px black;padding-top: 3px;background: #222;-webkit-box-shadow: 0px 0px 5px #000 inset;box-shadow: 0px 0px 5px #000 inset;"><b>' + item.artistname + '</b> - ' + displaySongName + '</span><div style="margin: -16px 0px 0px 20px;display: block;text-shadow: 1px 1px 1px black;padding-top: 3px;background: #222;height:36px;"><span style="font-size: 11px;color: #DDD;text-shadow: 1px 1px 1px black;vertical-align:bottom;">' + displayAlbumName + '</span>';
			
			if (item.ituneslink != null && item.ituneslink != '') {
				windowInnerHTML += '<a href="' + item.ituneslink + '" target="_blank" onclick="GSEfireCustomEvent(\'itunes\',\'' + item.artistname + ' - ' + item.songname + '\');return true;"><img ALIGN=RIGHT src="' + chrome.extension.getURL('itunes.png') + '" title="Buy song on ITunes" style="margin: 0px 4px 0px 0px;"></a>';
			}
			
			if (item.amazonlink != null && item.amazonlink != '') {
				windowInnerHTML += '<a href="' + item.amazonlink + '" target="_blank" onclick="GSEfireCustomEvent(\'amazon\',\'' + item.artistname + ' - ' + item.songname + '\');return true;"><img ALIGN=RIGHT src="' + chrome.extension.getURL('amazon.png') + '" title="Buy song on Amazon" style="margin: 0px 4px 0px 0px;"></a>';
			}
			
			if (item.youtubelink != null && item.youtubelink != '') {
				windowInnerHTML += '<a href="' + item.youtubelink + '" target="_blank" onclick="GSEfireCustomEvent(\'youtube\',\'' + item.youtubelink + '\');return true;"><img ALIGN=RIGHT src="' + chrome.extension.getURL('youtube.png') + '" title="Listen on Youtube" style="margin: 0px 4px 0px 0px;"></a>';
			}
			
			if (item.gssongid != null && item.gssongid != '') {
				windowInnerHTML += '<a onclick="GSEfireCustomEvent(\'GSSong\', ' + item.gssongid + ');return false;"><img ALIGN=RIGHT src="' + chrome.extension.getURL('gs.png') + '" title="Listen on Grooveshark" style="cursor:pointer;margin: 0px 4px 0px 0px;"></a>';
			}
			
			windowInnerHTML += '</div></div>'
		});
	
		var plowResultsDivHeightStyle = '';
		if (result.results.length > 5) {
			plowResultsDivHeightStyle = 'height: 435px;'
		}
		
		windowInnerHTML = getWindowHeaderHTML(result.searchterm) + '<div id="plowresults" class="plowresultsstyle" style="overflow-y: scroll; margin-top: -5px;' + plowResultsDivHeightStyle + 'overflow-x: hidden; width: 428px;">' + windowInnerHTML + '</div>';
		WriteEventToGoogleAnalyticsWithValue('Extension Open', 'Extension Open', result.searchterm.toLowerCase(), result.results.length);
		showOverlay(windowInnerHTML);
	}
};

function getWindowHeaderHTML(initialValue) {
	return '<a href="#" onclick="GSEfireCustomEvent(\'CloseWindow\',0);return false;" style="background-image: url(' + chrome.extension.getURL('close.png') + ');position: absolute;right: -18px;top: -20px;height: 35px;width: 35px;" ></a><div style="display: block"><span class="deleteicon"><input type="text" id="MusicPlowSearchTest" value="' + initialValue + '" style="font-size:larger;border: 1px solid black;background-color:#222;color: white;-webkit-border-radius:6px;margin-top: 5px;margin-bottom: 5px;margin-left: 5px;font-family: Verdana, Helvetica, sans-serif;display: inline;width: 382px;height: 35px" onkeydown="if (event.keyCode == 13) document.getElementById(\'MusicPlowSearchButton\').click();" /><span id="MusicPlowSearchButton" onclick="GSEfireCustomEvent(\'Search\',document.getElementById(\'MusicPlowSearchTest\').value);"></span></div>'
};

function showLoader() {
	showOverlay('<img src="' + chrome.extension.getURL('loader.gif') + '" />');
	document.getElementById("overlaywindowdiv").setAttribute("style", "width: 220px; height:19px; position: fixed; top: 50%; margin-top: -10px; left: 50%; margin-left: -110px;z-index: 10001;");
};

function showOverlay(windowText) {
	document.getElementById("overlaydiv").setAttribute("class","overlayshow");
	document.getElementById("overlaydiv").setAttribute("style", "width: 100%;height:100%;background-color: black;position: fixed;margin: 0; padding: 0;top: 0;left: 0;z-index: 10000;");
	document.getElementById("overlaywindowdiv").setAttribute("class","overlaywindowshow");
	document.getElementById("overlaywindowdiv").setAttribute("style", "background-image:url('" + chrome.extension.getURL('bgimage.jpg') + "');direction:ltr;width: 420px; text-align: left; position: fixed; top: 50%; margin-top: -150px; left: 50%; margin-left: -200px;z-index: 10001;-webkit-border-radius:8px;-webkit-box-shadow:0 0 7px 7px #888;");
	document.getElementById("overlaywindowdiv").innerHTML = windowText;
};

function ShowMessage(windowText) {
	showOverlay('<br><center style="font-size: 20px;color: #DDD;text-shadow: 1px 1px 1px #DDD;vertical-align:bottom;">' + windowText + '</center><br>');
	setTimeout("hideOverlay();", 2500);
}

function showNoResultsOverlay(searchTerm, didYouMeanTerm) {
	var noResultsHTML = getWindowHeaderHTML(searchTerm);
	noResultsHTML = noResultsHTML + '<div style="margin-bottom: 5px;margin-left: 10px;font-family: Verdana, Helvetica, sans-serif;display: block;line-height: 20px;width: 408px;font-size: 14px;color: #DDD;"><span style="font-size: 14px;color: #DDD;">Your search - <b>' + searchTerm + '</b> - didn\'t match any songs.</span>';
	if (didYouMeanTerm != null) {
		noResultsHTML += '<br>Did you mean - <a href="javascript: void(0)" style="color: #EEE;" onclick="GSEfireCustomEvent(\'DidYouMean\', \'' + didYouMeanTerm + '\');return false;"><b>' + didYouMeanTerm + '</b></a>'
	}
	noResultsHTML += '</div>'
	showOverlay(noResultsHTML);
};

function showErrorResultsOverlay() {
	ShowMessage('Oops. something went wrong, please try again later.');
};

function showOnlyYoutubeOverlay() {
	ShowMessage('Only Youtube links are supported at the moment.');
};

function hideOverlay() {
	document.getElementById("overlaywindowdiv").setAttribute("class","overlaywindowhide");
	document.getElementById("overlaydiv").setAttribute("style", "z-index: -10000;");
	document.getElementById("overlaydiv").setAttribute("class","overlayhide");
	document.getElementById("overlaywindowdiv").setAttribute("style", "z-index: -10001;");
};